package org.xiaojinlong.exam;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class A3602 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int total = scanner.nextInt();

        String[] str = new String[total];
        for (int i = 0; i < total; i++)
            str[i] = scanner.next();

        for (int i = 0; i < total; i++) {
            char[] c = str[i].toCharArray();
            List<Character> list = new ArrayList<Character>();

            for (char ch : c)
                list.add(ch);

            for (int j = 0; j < list.size(); j++) {
                if (list.get(j) == '#') {
                    if(j == 0) {
                        list.remove(j);
                        j --;
                    } else {
                        list.remove(j);
                        list.remove(j - 1);
                        j--;
                        j--;
                    }
                } else if (list.get(j) == '@') {
                    if(j == 0) {
                        list.remove(j);
                        j --;
                    } else {
                        int n = j;
                        while (n >= 0) {
                            list.remove(n);
                            n--;
                            j--;
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (Character ch : list)
                sb.append(ch);
            System.out.println(sb);
        }
    }
}

